package com.example.delayqueue.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @version 1.0.0
 * @className: DeadLetterConsumer
 * @description: 监听延迟队列 QD的消息
 * @see com.example.delayqueue.config.TtlQueueConfig
 * @author: LiJunYi
 * @create: 2022/8/4 12:58
 */
@Component
@Slf4j
public class DeadLetterConsumer
{
    /**
     * 收到了
     *
     * @param msg     信息
     * @param channel 通道
     * @throws Exception 异常
     */
    @RabbitListener(queues = {"QD"})
    public void receiveD(Message msg, Channel channel) throws Exception{
        String result = new String(msg.getBody());
        log.info("当前时间:{},收到死信队列的消息: {}",new Date(),result);
    }
}
